# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Dan McGee <dan@archlinux.org>
# Contributor: Martin Striz <ms@poruba.net>

pkgname=irqbalance
pkgver=1.8.0
pkgrel=1
pkgdesc="IRQ balancing daemon for SMP systems"
arch=('x86_64')
url="https://github.com/irqbalance/irqbalance"
license=('GPL2')
backup=('etc/irqbalance.env')
depends=('glibc')
makedepends=('glib2' 'libcap-ng' 'ncurses' 'numactl' 'systemd' 'systemd-libs')
source=("$pkgname-$pkgver.tar.gz::https://github.com/${pkgname}/${pkgname}/archive/v$pkgver.tar.gz")
sha512sums=('3d757198dbe680b010ed9233d73cbf3b4a150e6b07ef97d3e94f5fa0472a22b0b3800868634340fb413a18683ff95ff6a8f7fa51ace65d870651336479e32740')
b2sums=('0181ee57c4ddbdb55e1529cfd7da4b875320eff65cb606f925f0b4f4243b51e1349d4aba38690a78d7deab6d3f55ae8d6c45af44a904f03d7127678202f288db')

prepare() {
  cd "$pkgname-$pkgver"
  # fix location of configuration and binary in service
  sed -e 's|/path/to/|/etc/|g' \
      -e 's|/usr/sbin|/usr/bin|g' \
      -i "misc/${pkgname}.service"
  autoreconf -vfi
}

build() {
  cd "$pkgname-$pkgver"
  ./configure --prefix=/usr \
              --sbindir=/usr/bin \
              --with-systemd
  make
}

package() {
  depends+=('libglib-2.0.so' 'libcap-ng.so' 'libncursesw.so' 'libnuma.so' 'libsystemd.so')
  cd "$pkgname-$pkgver"
  make install DESTDIR="$pkgdir"
  install -vDm 644 misc/irqbalance.service \
    -t "${pkgdir}/usr/lib/systemd/system/"
  install -vDm 644 misc/irqbalance.env -t "${pkgdir}/etc/"
  install -vDm 644 {AUTHORS,README.md} -t "${pkgdir}/usr/share/doc/${pkgname}"
}
